[Bug Fix] #620132: Prevent IRS 1099 data on vendor ledger entries of non-1099 vendors - #9880
[Bug Fix] #620132: Prevent IRS 1099 data on vendor ledger entries of non-1099 vendors#9880ventselartur wants to merge 5 commits into
Conversation
Bug #620132: It is possible to specify 1099 information in vendor ledger entry even though the vendor is not 1099 Root Cause: - The OnValidate triggers of "IRS 1099 Reporting Period", "IRS 1099 Form No." and "IRS 1099 Form Box No." in tableextension 10035 "IRS 1099 Vendor Ledger Entry" only guarded against entries already linked to an IRS 1099 form document. Nothing verified that the vendor is subject to 1099 reporting, so a user could assign a reporting period, form and form box on the Vendor Ledger Entries page for a vendor with no "IRS 1099 Vendor Form Box Setup" record at all. Changes: - Added CheckVendorSubjectFor1099Reporting to codeunit 10037 "IRS 1099 Vendor Form Box". It exits for a blank period and otherwise errors when no "IRS 1099 Vendor Form Box Setup" record exists for the (period, vendor) pair. - Called the new check from the three OnValidate triggers in tableextension 10035, guarded so that clearing the fields remains allowed. Test Coverage: - ValidateIRS1099PeriodOnVendLedgEntryForNon1099Vendor (new, reproduces the bug) - ValidateIRS1099FormBoxOnVendLedgEntryFor1099Vendor (new, regression guard) - ClearIRS1099PeriodOnVendLedgEntryForNon1099Vendor (new, clearing stays allowed) - 42/42 tests in codeunit 148010 "IRS 1099 Document Tests" pass - Number of fix iterations: 1 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b132ff13-1ace-428c-a844-844eee2d1932
Add the [FEATURE] [AI test] marker above the [SCENARIO 620132] line in the three new tests, matching the convention used by the other tests in the IRSForms test codeunits. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: b132ff13-1ace-428c-a844-844eee2d1932
Agentic PR Review - Round 1Recommendation: Accept with SuggestionsWhat this PR doesThis PR fixes a gap in IRS 1099 data entry: the three The fix adds a new procedure SuggestionsS1 - S2 - Risk assessment and necessityRisk: The change adds validation at the table level on three Necessity: The fix is clearly needed. Allowing non-1099 vendor ledger entries to carry IRS reporting data is a data integrity problem: those entries would be included in incorrect 1099 form calculations. The change is well-scoped and targeted.
|
|
The build's new-warning gate failed on two AA0206 diagnostics in the IRS Forms test project. Both new tests assigned the result of CreateSingleFormBoxInReportingPeriod to a FormBoxNo variable that was never read. The call is kept as a statement so the form box is still created as part of the test setup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c74e438
Agentic PR Review - Round 2Recommendation: Accept with SuggestionsWhat this PR doesThe PR adds table-level validation so IRS 1099 fields on a vendor ledger entry cannot be set for a vendor that has no IRS 1099 Vendor Form Box Setup record for the selected period. The new round only removes unused local variables from two tests, so it does not change the product behavior. The product fix is still targeted. It checks the vendor and period before setting the three IRS 1099 fields and still allows clearing the period. The remaining review points are about test strength and one direct-validation edge case from round 1. Status of previous suggestions
New observations (commits since round 1)None - the new commit only removes unused variables from tests. Risk assessment and necessityRisk: The product change adds validation to posted vendor ledger entry IRS 1099 fields in the US IRS Forms app. This can block imports or background jobs that previously set these fields for vendors without 1099 setup, but that is the invalid data path the bug describes. The latest commit is test-only cleanup and has very low regression risk. Necessity: The change is needed because non-1099 vendors should not carry IRS reporting data on vendor ledger entries. The scope remains narrow and tied to the bug scenario.
|
|
- Raise an actionable ErrorInfo with a navigation action to the IRS 1099 Vendor Form Box Setup page instead of a dead-end Error dialog - Make ValidateIRS1099FormBoxOnVendLedgEntryFor1099Vendor set a reporting period first so it actually exercises the new vendor-setup guard - Add a negative test covering the IRS 1099 Form No. and Form Box No. guards for a vendor without 1099 setup Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Agentic PR Review - Round 3Recommendation: Accept with SuggestionsWhat this PR doesThis PR blocks IRS 1099 fields on vendor ledger entries when the vendor has no IRS 1099 Vendor Form Box Setup for the selected reporting period. The latest commit addresses review feedback by making the positive test validate the reporting period and form before the form box, adding negative tests for The main data-integrity path is now covered better. The validation still checks the keyed Status of previous suggestions
New observations (commits since round 2)None - the new commit adds the missing test coverage for the main data-integrity path and improves the error message action. The remaining open point is still S2 from the earlier review. Risk assessment and necessityRisk: The product change affects editable IRS 1099 fields on posted vendor ledger entries in the US IRS Forms app. It can now stop imports, page edits, or background code that tries to stamp IRS data on a non-1099 vendor, but that is the invalid data path the bug is meant to prevent. The latest commit is test and error-message work, so its new regression surface is small. Necessity: The change is needed because non-1099 vendors should not carry IRS reporting data on vendor ledger entries. The scope remains narrow, and the tests now cover the financial data-integrity path that must be protected.
|
Bug Reference
ADO work item #620132 — It is possible to specify 1099 information in vendor ledger entry even though the vendor is not 1099
Summary
IRS 1099 fields on a vendor ledger entry could be filled in for a vendor that is not subject to 1099 reporting. This PR adds a validation that the vendor has an
IRS 1099 Vendor Form Box Setuprecord for the selected reporting period before any of the IRS 1099 fields can be set on the entry.Root Cause
The
OnValidatetriggers ofIRS 1099 Reporting Period(10031),IRS 1099 Form No.(10032) andIRS 1099 Form Box No.(10033) intableextension 10035 "IRS 1099 Vendor Ledger Entry"only calledIRS1099FormDocument.CheckIfVendLedgEntryAllowed, which blocks edits on entries already linked to an IRS 1099 form document. Nothing verified that the vendor is subject to 1099 reporting. Because these fields are editable onpageextension 10048 "IRS 1099 Vendor Ledger Entries", a user could assign a reporting period / form / form box to a ledger entry of a vendor with no 1099 setup at all.Changes Made
src/Apps/US/IRSForms/app/src/VendorFormBox/IRS1099VendorFormBox.Codeunit.al: addedCheckVendorSubjectFor1099Reporting(VendorNo; PeriodNo). It exits when the period is blank (so clearing the fields is always allowed) and otherwise raisesVendor %1 is not set up for IRS 1099 reporting in the reporting period %2.when noIRS 1099 Vendor Form Box Setuprecord exists for that (period, vendor) pair.src/Apps/US/IRSForms/app/src/Extensions/IRS1099VendorLedgerEntry.TableExt.al: the threeOnValidatetriggers now call the new check, guarded by a non-blank test on the field being validated so clearing a field remains unconditionally allowed.src/Apps/US/IRSForms/test/src/IRS1099DocumentTests.Codeunit.al: three new tests (see below).report 10038 "IRS 1099 Propagate Vend. Setup"validates the same three fields, but only for vendors that already have anIRS 1099 Vendor Form Box Setuprecord, so it is unaffected — confirmed by the full test run.Implementation Process
Test Evidence
Test run: codeunit 148010 "IRS 1099 Document Tests" on an on-premise NST (US localization).
Pre-Fix Test Results (Baseline)
Baseline run against the unfixed product code:
Post-Fix Test Results (Final)
Full codeunit run: 39 passed, 2 failed.
Pre-existing failures (NOT caused by this change)
Both failures were reproduced on this environment with the product fix reverted, and fail
identically with and without the change:
IRS1099CodeInPurchaseHeaderWhenChangePostingDateAfterAddingLineIRS 1099 Reporting Amount must be equal to '-1.13' ... Current value is '-1'PartialPaymentCreatesLineDetailWithDifferentCalculatedAndReportingAmountsCannot post because one or more transactions have dates after the working dateIteration Summary
IRS 1099 Vendor Form Box Setupkey because it assigned a second form box for the same (period, vendor). Test corrected.Test Coverage
Testing Checklist
IRS 1099 Reporting Period/Form No./Form Box No.— an error should appearGetper field validationReview Notes
IRS 1099 Vendor Form Box Setup(period + vendor), the same source of truth used byUpdateIRSDataInPurchHeaderandGetVendorIRS1099FormBoxSetupAsOfDate.🤖 Generated by the bc-fix-bug skill
AB#620132